home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
nospace.zip
/
NOSPACE.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1993-01-04
|
4KB
|
117 lines
PROGRAM NoSpace; {$L+,D+,E-,I+,S-,M 2000,0,2000}
uses DOS, Crt, Mytools;
VAR
drive : word;
BytesToCheck : longint; {Variable integer for Disk Space}
MBytesFreeStr: string[30]; {String form of avail. disk space}
Err : integer;
StrDrive : string[1];
ParsedParam : string[1];
pause : char;
PROCEDURE DispErrs;
begin
IF ParamCount = 0 THEN ClrScr;
Writeln;
Writeln;
Writeln('This program warns the user when a disk drive of his own selection');
Writeln('becomes nearly full. The syntax is: Nospace <drive> <bytes for warning msg>');
Writeln('If no parameters are passed on the command line, then you see this message.');
Writeln('Syntax is: nospace <drive> <bytes> where <drive> = drive to check and');
Writeln('<bytes> = free bytes for the warning message.');
Writeln;
Writeln('Example in autoexec.bat file: nospace c: 2000000');
Writeln;
Writeln('This program has been put into the public domain and may not be sold. It may');
Writeln('be copied freely and distributed where it may serve some use. The author is');
Writeln('Larry Williams and I intend no further updates at this time.');
IF ParamCount = 0 THEN Halt(100);
end;
PROCEDURE DispErrs1;
begin
ClrScr;
Write(Chr(7));
Writeln;
AWrite(2,1,112,'ERROR: You must enter TWO parameters. Please see below. ');
Disperrs;
Halt(99);
end;
PROCEDURE DispErrs2;
begin
ClrScr;
Write(Chr(7));
AWrite(2,1,112,'ERROR: The valid options for drives are: A - Z ');
Disperrs;
Halt(98);
end;
PROCEDURE DispErrs3;
begin
ClrScr;
Write(Chr(7));
Writeln;
AWrite(2,1,112,'ERROR: You cannot enter more than two parameters, see below. ');
Disperrs;
Halt(97);
end;
PROCEDURE IllegalDrive;
{presently only works if the colon is put after the illegal drive letter}
{need to parse the parameter to only one char}
begin
TextAttr := 7; {makes sure standard video is displayed - gray on black}
ClrScr;
Write(Chr(7));
ABox(4,22,3,35,112,112,Border6,True);
AWriteC(5,112,'Drive ' + StrDrive + ' is an Unknown Drive');
Delay(1500);
Halt(0);
end;
PROCEDURE GoFigure; {Procedure to calculate if avail disk space ok}
var
tempdrive : byte;
tempchar : char;
begin
IF ParamCount = 2 THEN VAL(ParamStr(2),BytesToCheck,Err);
{If 2 params, evaluate which is larger}
StrDrive := UCase(ParamStr(1)); {Return uppercase Drive letter as string}
tempdrive := ord(StrDrive[1]); {get ASCII Val of uppcase letter}
{ ParsedParam := first char of StrDrive;}
Drive := ord(tempdrive) - 64; {evaluate whether it is A-Z (1-26)}
IF ((Drive > 26) OR (Drive < 1)) THEN DispErrs2;
end;
{+++++++++ MAIN PROGRAM LOOP +++++++++++++++++++++++++++++++++++++++++++}
BEGIN
IF ParamCount = 0 THEN DispErrs ELSE
IF ParamCount = 1 THEN DispErrs1 ELSE
IF ParamCount = 2 THEN GoFigure;
IF ParamCount > 2 THEN DispErrs3;
IF DiskFree(drive) < 0 THEN IllegalDrive; {check for invalid drive}
{if bytes avail > specified no. of bytes, do nothing}
IF DiskFree(drive) > BytesToCheck THEN HALT(0);
TextAttr := 7;
ClrScr;
Write(Chr(7));
ABox(9,15,5,50,112,112,Border3,True);
AWriteC(10,112,'Warning: LOW DISK SPACE on Drive '+ StrDrive + ':');
{Convert bytes avail to string}
{bytes avail divided by 1 meg = mbytes avail}
Str(DiskFree(drive)/1000000:3:1,MBytesFreeStr);
AWriteC(12,112,('Free bytes available: '+MBytesFreeStr+' Megabytes'));
GotoXY(1,1);
Delay(1500) {pause}
END.